home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13307 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help:what is wrong this code?
  5. Date: 6 Apr 1996 01:31:47 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4k4hi3$5hm@sparcserver.lrz-muenchen.de>
  9. References: <4k3p3q$n76@brahms.udel.edu>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. yuehong@brahms.udel.edu (Yue-hong Zheng) writes:
  13.  
  14.  
  15. >Why it give me 0.0000?
  16.  
  17. >#include <stdio.h>
  18. >main () {
  19. >double a=9.008;
  20. >printf("%f\n",sqrt(a));
  21. >return 0;
  22. >}
  23.  
  24. Could the FAQ "I'm trying to take some square roots, but I'm
  25. getting crazy numbers" be somehow related to your question?
  26. I mean, this is almost exactly the question you ask, and the
  27. answer given in the FAQ is the right answer for your problem.
  28.  
  29. Hint: sqrt() in not declared in <stdio.h> and the description 
  30. "function taking an unspecified number of parameters and returning
  31. int", i.e. the default type for a function that has not been
  32. previously declared, is not exactly correct for sqrt(). You
  33. _need_ a declaration for all functions that are either variadic
  34. or do not return "int".  
  35.  
  36. Kurt
  37. --
  38. | Kurt Watzka                             Phone : +49-89-2180-6254
  39. | watzka@stat.uni-muenchen.de
  40.  
  41.  
  42.